#e
#Title[ug|l}Xrw[^-Easy-v]
#Text[G@ĹuJ}v]
#ScriptVersion[2]
#PlayLevel[Easy]
#Player[FREE]

script_enemy_main{
 let wIni = 120;
 let img = "script\img\ExRumia.png";
 let name = "ug|l}Xrw[^-Easy-v";

 @Initialize {
  CutIn(KOUMA, name, "", 0, 0, 0, 0);
  SetMovePosition02(GetCenterX, GetCenterY, 120);
  SetLife(10000);
  SetScore(2000000);
  SetDamageRate(80, 0);

  LoadGraphic(img);
  SetTexture(img);
  SetGraphicRect(64, 0, 128, 64);

  TMain;
 }

 @MainLoop {
  SetCollisionA(GetX, GetY, 32);
  SetCollisionB(GetX, GetY, 24);

  yield;
 }

 @DrawLoop {
  DrawGraphic(GetX, GetY);
 }

 @Finalize {
  DeleteGraphic(img);
 }

 task TMain {
  yield;

  loop {
   CreateReflectShot(GetX, GetY, 2, rand(0, 360), PURPLE02, 10);
   loop(300) { yield; }
  }
 }

 task CreateReflectShot(x, y, speed, angle, graphic, delay) {

  let obj = Obj_Create(OBJ_SHOT);

  Obj_SetPosition(obj, x, y);
  Obj_SetSpeed(obj, speed);
  Obj_SetAngle(obj, angle);
  ObjShot_SetGraphic(obj, graphic);
  ObjShot_SetDelay(obj, delay);
        
  loop(delay) { yield; }
        
  while(! Obj_BeDeleted(obj)) {

   if(Obj_GetX(obj) < GetClipMinX) {
    Obj_SetX(obj, GetClipMinX * 2 - Obj_GetX(obj));
    Obj_SetAngle(obj, 180 - Obj_GetAngle(obj));
   }

   if(Obj_GetX(obj) > GetClipMaxX) {
    Obj_SetX(obj, GetClipMaxX * 2 - Obj_GetX(obj));
    Obj_SetAngle(obj, 180 - Obj_GetAngle(obj));
   }

   if(Obj_GetY(obj) < GetClipMinY){
    Obj_SetY(obj, GetClipMinY * 2 - Obj_GetY(obj));
    Obj_SetAngle(obj, 360 - Obj_GetAngle(obj));
   }

   if(Obj_GetY(obj) > GetClipMaxY){
    Obj_SetY(obj, GetClipMaxY * 2 - Obj_GetY(obj));
    Obj_SetAngle(obj, 360 - Obj_GetAngle(obj));
   }

   yield;
  }
 }

}
